#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int main()
{
	int n = 0;
	do
	{
		cin >> n;
	} while (n >= 3000 && n % 3 != 0);
	int a[3000] = { 0 };
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int price = 0;
	for (int j = 0; j < n; j = j + 3)
	{
		price += a[j];
	}
	cout << price << endl;
	return 0;
}
